<?php

namespace Hilaoyu\LaravelExtend\Services\AccessControl;

use Hilaoyu\LaravelExtend\Entity;
use Hilaoyu\Utils\UtilHtml;

abstract class AbstractEntityAccessControlEntities extends Entity
{

    public function buildTypeOptions($selected=[],$add_title=''){
        $add_title = trim($add_title);
        $options = [];

        foreach ($this->model()::GetAllowTypes() as $key => $name){
            $options[] = ['value'=>$key,'label'=>$name];
        }

        if($add_title){
            array_unshift($options,['value'=>'','label'=>$add_title]);
        }

        return UtilHtml::formatHtmlOptions($options,'value','label','',$selected);
    }

}
